<?php
// -----------------------------------------------------------------------------
// include
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------

if (!(isset($_POST["title"]) && isset($_POST["content"]))) {
    exit("需要传入有效的参数！");
}

$title = $_POST["title"];
$content = $_POST["content"];

// -----------------------------------------------------------------------------
// 时区设置
// -----------------------------------------------------------------------------

date_default_timezone_set($region);
$timeCreate = (string)time();
$timeEdit = $timeCreate;
$sortNumber = $timeCreate;

// -----------------------------------------------------------------------------
// 数据库相关设置
// -----------------------------------------------------------------------------

$dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
$db = new DBManager("sqlite:" . $dbPath);

// -----------------------------------------------------------------------------

$arr = [];
$arr["title"] = $title;
$arr["content"] = $content;
$arr["sortNumber"] = $sortNumber;
$arr["timeCreate"] = $timeCreate;
$arr["timeEdit"] = $timeEdit;

$db->insertIntoShoppingList($arr);

// -----------------------------------------------------------------------------

echo <<<BBB
创建成功！
BBB;
